<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<style type="text/css">
	body {
		background: #404066;
		color: #000000;
		font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
		margin: 5px 10px 10px 10px;
		padding: 0px;
		overflow: hidden;
	}
	h1 {
		color: darkblue;
		font :bold 16pt verdana,geneva,lucida,'lucida grande',arial,helvetica,sans-serif;
		margin-top: 0
	}
	.title {
		text-align: center;
	}
	h2 {
		color:darkblue;
		font:bold 14pt verdana,geneva,lucida,'lucida grande',arial,helvetica,sans-serif
	}
	h3 {
		color:darkblue;
		font:bold 12pt verdana,geneva,lucida,'lucida grande',arial,helvetica,sans-serif
	}
	h4 {
		color:#b73235;
		font:bold 10pt verdana,geneva,lucida,'lucida grande',arial,helvetica,sans-serif
	}
	pre {
		font: 10pt parallax,courier,monospaced;
		line-height: 97%;
	}	
	.source {
		margin-left: 20px;
		border: 1px solid #ccc;
		overflow: auto;
		display: none;
		background: #f8f8e8;
		margin-top: 12pt;
		width: 95%;
		padding-top: 5px;
		padding-left: 10px;
		max-height: 600px;
		letter-spacing: 0px;
	}
	var {
		color: #000080;
		font-style: normal;
		font-weight: bold;
		letter-spacing: -1px;
	}
	a {
		font-weight: bold;
		font-size: 6pt;
		text-decoration: none;
		color: #0000cc;
	}
	.toc1 {
		font-size: 12pt;
		font-weight: bold;
		vertical-align: baseline;
		text-align: center;
		color: #d7d0ff;
	}		
	.toc2 {
		font-size: 95%;
		font-weight: bold;
		vertical-align: baseline;
		color: white;
		text-decoration: none;
	}		
	.toc3 {
		font-size: 90%;
		font-weight: normal;
		vertical-align: baseline;
		margin-left: 10px;
		color: white;
		text-decoration: none;
	}		
	.toc4 {
		font-size: 85%;
		font-weight: normal;
		font-style: italic;
		vertical-align: baseline;
		margin-left: 20px;
		color: #d7d0ff;
		text-decoration: none;
	}
	.tocgrp {
		display: none
	}
  hr {
  	border: 0;
    color: #b73235;
    background-color: #b73235;
    height: 1px;
  }
	</style>
	<script language="JavaScript">
		window.onload = resize;
		window.onresize = resize;
		var show=0;
		function ShowHide(divId) {
			if (document.getElementById(divId).style.display!='block') {
				document.getElementById(divId).style.display='block';
				if (divId.substring(0, 3) == 'toc') {
					window.location = '#lbl' + divId.substring(3);
				}
			} else {
				document.getElementById(divId).style.display='none';
			}
		};
    function resize() {
      var myWidth = 0, myHeight = 0;
      if(typeof(window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
      } else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
      } else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
      }
      document.getElementById("text").style.height = (myHeight - 10) + "px";
      document.getElementById("text").style.width = (Math.min(myWidth - 250, 800)) + "px";
      document.getElementById("toc").style.height = (myHeight - 10) + "px";
     }	
    function selectall(source) { 
	    var selection, range, doc, win; 
	    if ( (doc = source.ownerDocument)
	    	&& (win = doc.defaultView)
	    	&& typeof win.getSelection != 'undefined'
	    	&& typeof doc.createRange != 'undefined' 
	    	&& (selection = window.getSelection())
	    	&& typeof selection.removeAllRanges != 'undefined'
	    ) { 
	       range = doc.createRange(); 
	       range.selectNode(source); 
	       selection.removeAllRanges(); 
	       selection.addRange(range); 
	    } else if (document.body && typeof document.body.createTextRange != 'undefined' && (range = document.body.createTextRange())) { 
	       range.moveToElementText(source); 
	       range.select(); 
	    } 
		}
  </script>
</head>
<body style = "margin: 0 0 0 0;">
<div align=center>
<table cellpadding=0 cols=2 border=0>
	<tr><td valign="top">
	<div id="toc" style= "width: 200px; height: 600px; overflow: auto; background-color: #222255; border-left: solid #ffffe0"><br/>
		<div style="background-color:#222255; width: 100%; text-align: center">
		<img src="data:image/gif;base64,
			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
		">
		</div>
		<div style="font: bold 11pt verdana,geneva,lucida,'lucida grande',arial,helvetica,sans-serif;color:white; text-align: center; margin-bottom: 10px; margin-top: 10px">NETBIOS</div>
		<p class = "toc1">Table of Contents</p>
		<div style = "text-align: left; margin-left: 10px;">
			<a href= "#lbl1" class = "toc2">Preface</a><br/>
<a onclick ="javascript:ShowHide('toc2')" href="javascript:;" class = "toc2">Global CONstants ... </a><br />
<div id= "toc2" class = "tocgrp">
</div>
<a href= "#lbl4" class = "toc2">Global DATa </a><br/>
<a href= "#lbl6" class = "toc2">Used OBJects </a><br/>
<a href= "#lbl8" class = "toc2">PUBlic Spin Methods</a><br/>
<a href= "#lbl9" class = "toc4">Init</a><br/>
<a href= "#lbl11" class = "toc4">CheckSocket</a><br/>
<a href= "#lbl13" class = "toc4">CheckBuffer</a><br/>
<a href= "#lbl15" class = "toc4">GetLastSendPtr</a><br/>
<a href= "#lbl17" class = "toc4">DisconnectSocket</a><br/>
<a href= "#lbl19" class = "toc4">ReInitSocket</a><br/>
<a href= "#lbl21" class = "toc4">SendQuery</a><br/>
<a href= "#lbl23" class = "toc4">GetLastReadSize</a><br/>
<a href= "#lbl25" class = "toc4">GetLastIP</a><br/>
<a href= "#lbl27" class = "toc4">DecodeLastNameInplace</a><br/>
<a href= "#lbl29" class = "toc4">GetLastName</a><br/>
<a onclick ="javascript:ShowHide('toc31')" href="javascript:;" class = "toc2">PRIvate Spin Methods ... </a><br />
<div id= "toc31" class = "tocgrp">
<a href= "#lbl32" class = "toc4">SendRegister</a><br/>
<a href= "#lbl34" class = "toc4">SendResponse</a><br/>
<a href= "#lbl36" class = "toc4">WaitForCountBytes</a><br/>
<a href= "#lbl38" class = "toc4">FirstLevelEncode</a><br/>
<a href= "#lbl40" class = "toc4">FirstLevelDecode</a><br/>
<a href= "#lbl42" class = "toc4">CreateTransactionId</a><br/>
</div>
<a href= "#lbl44" class = "toc2">Documentation </a><br/>
<a href= "#lbl45" class = "toc2">MIT License </a><br/>

		</div>
	</div>
	</td>
	<td>
		<div id="text" style= "text-align: left; padding-left: 20px; padding-right: 20px; width: 800px; height: 600px; background-color: #ffffe0; overflow: auto">
			<h1 id = "lbl1" class = "title">NetBios </h1>

<br /><br />
AUTHORS:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Mike Gebhard / Michael Sommer<br />
COPYRIGHT:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;See LICENCE (MIT)&nbsp;&nbsp;&nbsp;&nbsp;<br />
LAST MODIFIED:&nbsp;&nbsp;&nbsp;&nbsp;10/28/2013<br />
VERSION:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.0<br />
LICENSE:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MIT (see end of file)<br /><br />
DESCRIPTION:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The NETBIOS object - original file was NetBiosUnitTest<br />
<br />
 This program partially implements NetBIOS name services<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* sending Registration<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* sending NB Name Query Response&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* sending NBSTAT Name Query Response<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* sending NB Name Query Negative Response (protecting names)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* sending Name Query Requests<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* and checking responses&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
RESOURCES:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://tools.ietf.org/html/rfc1001<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://tools.ietf.org/html/rfc1002<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://ubiqx.org/cifs/NetBIOS.html<br />
<br />
MODIFICATIONS:<br />
 9/2/2013&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;original file was NetBiosUnitTest.spin<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;created NetBios shrunk down as much as possible<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;added hostname. and workgoup to Init<br />
10/04/2013&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;added spindoc comments<br />
10/21/2013&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;added NB Name Query Negative Response (protecting names)&nbsp;&nbsp;<br />
10/24/2013&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;added RCODE enum&nbsp;&nbsp;<br />
10/28/2013&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nbtstat can now resolve group names and display entrys for each member.<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nbquery can now resolve group names and display entrys for each member.<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Michael Sommer (MSrobots)<br />
<br />
 Form a DOS prompt run nbtstat -a PROPNET.<br />
-----------------------------------------------------<br />
 C:\&gt;nbtstat -a PROPNET<br />
<br />
 Local Area Connection:<br />
 Node IpAddress: [192.168.1.103] Scope Id: []<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NetBIOS Remote Machine Name Table<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Status<br />
&nbsp;&nbsp;---------------------------------------------<br />
&nbsp;&nbsp;PROPNET&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;00&gt;&nbsp;&nbsp;UNIQUE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registered<br />
&nbsp;&nbsp;WORKGROUP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;00&gt;&nbsp;&nbsp;GROUP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registered<br />
<br />
&nbsp;&nbsp;MAC Address = 00-08-DC-16-F8-01<br />
-----------------------------------------------------<br />
<br />
 From a DOS prompt execute ping PROPNET<br />
-----------------------------------------------------<br />
 C:\&gt;ping PROPNET<br />
 <br />
 Pinging PROPNET [192.168.1.107] with 32 bytes of data:<br />
 <br />
 Reply from 192.168.1.107: bytes=32 time&lt;1ms TTL=128<br />
 Reply from 192.168.1.107: bytes=32 time&lt;1ms TTL=128<br />
 Reply from 192.168.1.107: bytes=32 time&lt;1ms TTL=128<br />
 Reply from 192.168.1.107: bytes=32 time&lt;1ms TTL=128<br />
 <br />
 Ping statistics for 192.168.1.107:<br />
&nbsp;&nbsp;&nbsp;&nbsp;Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),<br />
 Approximate round trip times in milli-seconds:<br />
&nbsp;&nbsp;&nbsp;&nbsp;Minimum = 0ms, Maximum = 0ms, Average = 0ms<br />
<br />
Error messages<br />
-------------------<br />
RCODE field values:<br />
<br />
Symbol&nbsp;&nbsp;&nbsp;&nbsp;Value&nbsp;&nbsp;&nbsp;Description:<br />
<br />
FMT_ERR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0x1&nbsp;&nbsp;&nbsp;Format Error.&nbsp;&nbsp;Request was invalidly<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;formatted.<br />
SRV_ERR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0x2&nbsp;&nbsp;&nbsp;Server failure.&nbsp;&nbsp;Problem with NBNS, cannot<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;process name.<br />
IMP_ERR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0x4&nbsp;&nbsp;&nbsp;Unsupported request error.&nbsp;&nbsp;Allowable only<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for challenging NBNS when gets an Update type<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;registration request.<br />
RFS_ERR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0x5&nbsp;&nbsp;&nbsp;Refused error.&nbsp;&nbsp;For policy reasons server<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;will not register this name from this host.<br />
ACT_ERR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0x6&nbsp;&nbsp;&nbsp;Active error.&nbsp;&nbsp;Name is owned by another node.<br />
CFT_ERR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0x7&nbsp;&nbsp;&nbsp;Name in conflict error.&nbsp;&nbsp;A UNIQUE name is owned by more than one node.<br />

<br />
<h2 id = "lbl2">Global CONstants </h2>
<br /><a onclick ="javascript:ShowHide('lbl3')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl3>  ZERO                          = $00
  CR                            = $0D
  LF                            = $0A
  SPACE                         = $20
  
  #0, CLOSED, TCP, UDP, IPRAW, MACRAW, PPPOE
  #0, OK, FMT_ERR, SRV_ERR, IMP_ERR, RFS_ERR, ACT_ERR, CFT_ERR

  NB                            = $20
  NB_STAT                       = $21

  { Packet Enum}
  TRANSACTION_ID                = $00
  FLAGS                         = $02
  QUESTIONS                     = $04
  ANSWERS                       = $06
  AUTHORITY                     = $08
  ADDITIONAL                    = $0A
  QUERY                         = $0C
  NB_1                          = $2E
  IN_1                          = $30
  TTL                           = $32
  DATA_LEN                      = $36
  NB_FLAGS                      = $38
  NB_IP                         = $3A

  { RCODE Error Enum }
  RCODE_FMT_ERR                 = $1  ' Format Error.  Request was invalidly formatted.
  RCODE_SRV_ERR                 = $2  ' Server failure.  Problem with NBNS, cannot
                                      ' process name.
  RCODE_IMP_ERR                 = $4  ' Unsupported request error.  Allowable only
                                      ' for challenging NBNS when gets an Update type
                                      ' registration request.
  RCODE_RFS_ERR                 = $5  ' Refused error.  For policy reasons server
                                      ' will not register this name from this host.
  RCODE_ACT_ERR                 = $6  ' Active error.  Name is owned by another node.
  RCODE_CFT_ERR                 = $7  ' Name in conflict error.
                                      ' A UNIQUE name is owned by more than one node.
  
  { CheckSocket Enum }
  CHECKSOCKET_NOTHING           = $0
  CHECKSOCKET_NB_SEND           = $1
  CHECKSOCKET_NBSTAT_SEND       = $2
  CHECKSOCKET_OTHER             = $3
  CHECKSOCKET_NEG_NB_SEND       = $4

</pre>
<hr />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
<h2 id = "lbl4">Global DATa </h2>
<br /><a onclick ="javascript:ShowHide('lbl5')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl5>
  
  encName          <var>byte</var> $0[33], $00
  encGroup         <var>byte</var> $0[33], $00
  encServer        <var>byte</var> $0[33], $00
  wildcard         <var>byte</var> $0[33], $00
                                                        '             R      ATRR   
                                                        '             E      ACDA   B
                                                        '             Q OPcd NMflags  Rcode
  nbNameReg        <var>byte</var> $68, $C8, $29, $10,             { trn flags: %0_0101_001000_1_0000
}                       $00, $01, $00, $00,             { QDcnt ANcnt (Questions[1] Answers)    
}                       $00, $00, $00, $01,             { NScnt ARcnt (Authority Additional[1]) - end header 
}                       $20, $0[32], $00,               { Question Name
}                       $00, $20, $00, $01,             { Qtype NB Qclass IN
}                       $C0, $0C,                       { ptr RR_NAME
}                       $00, $20, $00, $01,             { Rtype NB Rclass IN
}                       $00, $00, $00, $00,             { infinite TTL for broadcast 
}                       $00, $06, $00, $00              { RDlen(6) NB_FLAGS %0_00_00000_00000000}
  ipReg            <var>byte</var> $C0, $A8, $01, $68              { NB address (IP) }
  enbNameReg       <var>byte</var> 0,0,0,0
                                                         '%1_0000_101000_1_0000 wrong $85 $10
  nbPosQueryResp   <var>byte</var> $68, $C8, $85, $00,             { trn flags: %1_0000_101000_0_0000
}                       $00, $00, $00, $01,             { Questions Answers[1] 
}                       $00, $00, $00, $00,             { Authority Additional - end header 
}                       $20, $0[32], $00,               { RP_NAME
}                       $00, $20, $00, $01,             { NB IN
}                       $00, $04, $90, $E0,             { TTL = 10 minutes
}                       $00, $06, $00, $00              { NB_FLAGS %0_00_00000_00000000 }
  ipResp           <var>byte</var> $C0, $A8, $01, $68              { NB address (IP) }                       
  enbPosQueryResp  <var>byte</var> 0,0,0,0

                                                       '              R      ATRR   
                                                        '             S      ACDA   B
                                                        '             P OPcd NMflags  Rcode
  nbStatQueryResp  <var>byte</var> $68, $C8, $84, $00,             { trn flags: %1_0000_100000_0_0000
}                       $00, $00, $00, $01,             { Questions Answers[1] 
}                       $00, $00, $00, $00,             { Authority Additional - end header
}                       $20, $0[32], $00,               { RP_NAME (offset 13)
}                       $00, $21, $00, $01,             { NB IN
}                       $00, $00, $00, $00,             { 0 (TTL has no meaning in this context)
}                       $00, $66, $03,                  { Len = 102; names = 3 (*18) + 48
}                       "               ", $00,         { Hostname (offset 57)
}                       $04, $00,                       { flag ACT (active)
}                       "               ", $00,         { Workgroup (offset 75)
}                       $84, $00,                       { flag G (Group) ACT (active) 
}                       "               ", $20,         { Hostname (offset 93) FileServerService
}                       $04, $00                        { ACT (active) }    
  nbMac            <var>byte</var> $00, $08, $DC, $16, $F8, $01,   { MAC               
}                       $00, $00, $00, $00, $00, $00,   { Jumpers; <var>test</var>; version; stats
}                       $00, $00, $00, $00, $00, $00,   { CRC, alignment error; collitions
}                       $00, $00, $00, $00, $00, $00,   { aborts;  sends 
}                       $00, $00, $00, $00, $00, $00,   { receives; retransmits
}                       $00, $00, $00, $00, $00, $00,   { no resource; command block; pending session
}                       $00, $00, $00, $00, $00, $00,   { <var>max</var> pend sessions; <var>max</var> sessions; Session data size
}                       $00, $00, $00, $00, $00, $00    { padding }            
  enbStatQueryResp <var>byte</var> 0

                                                        '             R      ATRR   
                                                        '             E      ACDA   B
                                                        '             Q OPcd NMflags  Rcode
  nbNameQueryReq   <var>byte</var> $68, $C8, $01, $10,             { trn flags: %0_0000_001000_1_0000
}                       $00, $01, $00, $00,             { QDcnt ANcnt (Questions[1] Answers)    
}                       $00, $00, $00, $00,             { NScnt ARcnt (Authority Additional) - end header 
}                       $20, $0[32], $00,               { Question Name
}                       $00, $20, $00, $01              { Qtype NB Qclass IN }
  enbNameQueryReq  <var>byte</var> 0

  _ownip           <var>long</var>  $00
  _lastnbtstatip   <var>long</var>  $00
  _lastsendptr     <var>long</var>  $00     
  _buffPtr         <var>long</var>  $00
  _sockId          <var>long</var>  $00
  _lastReadSize    <var>long</var>  $00    ' last bytes read in sendreceive
  null             <var>long</var>  $00 

</pre>
<hr /><br />
<h2 id = "lbl6">Used OBJects </h2>
<br /><a onclick ="javascript:ShowHide('lbl7')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl7>
  sock          : "Socket"
  wiz           : "W5100"

</pre>
<hr /><br />
<h2 id = "lbl8">PUBlic Spin Methods</h2>
<hr /><h4 id = "lbl9">Init(buffer, socket, hostname , workgroup)
</h4>

<br />Init:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Init NetBios and register hostname and workgroup<br />
Returns:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 success &gt;0 NetBios Err ... see RCODE field values in CON section<br />

<br /><a onclick ="javascript:ShowHide('lbl10')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl10><var>PUB</var> Init(buffer, socket, hostname , workgroup) | tr1, tr2, tr3 'Init NetBios and register hostname and workgroup
  _buffPtr := buffer
  _sockId  := socket  
  ' Fill the hostname and workgroup into nbStatQueryResp
  <var>bytemove</var>(@nbStatQueryResp+57,hostname,<var>strsize</var>(hostname) &lt;# 15 )               ' host name
  <var>bytemove</var>(@nbStatQueryResp+75,workgroup,<var>strsize</var>(workgroup) &lt;# 15)              ' group
  <var>bytemove</var>(@nbStatQueryResp+93,hostname,<var>strsize</var>(hostname) &lt;# 15 )               ' host FileServer
                  
  'encode names  
  FirstLevelEncode(@wildcard, string("*"), ZERO, $00, <var>false</var>)
  FirstLevelEncode(@encName, hostname, SPACE, $00, <var>true</var>)
  FirstLevelEncode(@encGroup, workgroup, SPACE, $00, <var>true</var>)
  FirstLevelEncode(@encServer, hostname, SPACE, $20, <var>true</var>)                   
  
  'Fill in MAC &amp; IP
  <var>bytemove</var>(@nbMac, wiz.GetMac, 6)
  <var>bytemove</var>(@ipReg, wiz.GetIp, 4)
  <var>bytemove</var>(@ipResp, wiz.GetIp, 4)
  <var>bytemove</var>(@_ownip, @ipResp, 4)   
  
  ReInitSocket
  
  'Create 3 unique IDs
  tr1 := CreateTransactionId($FFFF)
  tr2 := CreateTransactionId($FFFF)
  tr3 := CreateTransactionId($FFFF)

  'Broadcast NetBIOS on port 137
  'Send the name registration request 3 times
  'If we do not get a response then the name is available
  
  nbNameReg[2] := $29                                   'RD bit 1 - NAME REGISTRATION REQUEST
  <var>repeat</var> 3
    sendRegister(tr1, @encName, 0)                      'no group
    sendRegister(tr2, @encServer, 0)                    'no group
    sendRegister(tr3, @encGroup, $80)                   'group
    sock.Available                                      'wait for responses (if any) 
    <var>repeat</var>                                              
      <var>if</var> CheckSocket == CHECKSOCKET_OTHER               'check incoming responses
        <var>RESULT</var> := (wiz.DeserializeWord(_buffPtr+constant(FLAGS+8)) &amp; $000F) ' RCODE error (any) 
          <var>if</var> (<var>RESULT</var>)                                   'yes
            <var>return</var> <var>RESULT</var>                               'exit with RCODE
    <var>until</var> _lastReadSize == 0                            'no more response
    
  nbNameReg[2] := $28                                   'RD bit 0 - NAME OVERWRITE DEMAND
  sendRegister(tr1, @encName, 0)                        'no group
  sendRegister(tr2, @encServer, 0)                      'no group
  sendRegister(tr3, @encGroup, $80)                     'group    

</pre>
<hr /><h4 id = "lbl11">CheckSocket
</h4>

<br />CheckSocket:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Checks NetBios Name Service and if there processes one request<br />
Returns:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;see CheckSocket Enum values in CON section<br />
                    buffer contains last received request/response
                    _lastReadSize contains 0 or size of received request/response
<br />
<br /><a onclick ="javascript:ShowHide('lbl12')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl12><var>PUB</var> CheckSocket  | avail, needed                        'checks NetBios Name Service and if there processes one request
  _lastReadSize := 0
  <var>if</var> sock.DataReady &gt; 0                                 'Any Data ?
    <var>if</var> ((avail := waitForCountBytes(8)) =&gt; 8)           'Header Data in the buffer?
      sock.Receive(_buffPtr, 8)                         'Get udp header
      needed := wiz.DeserializeWord(_buffPtr + 6)       'size packet
      <var>if</var> ((avail := waitForCountBytes(needed)) =&gt; needed)'Data there?
        sock.Receive(_buffPtr+8, needed)
        _lastReadSize := needed + 8                     'remember last block size
        <var>RESULT</var> := CheckBuffer(<var>false</var>)                    'data in buffer not query

</pre>
<hr /><h4 id = "lbl13">CheckBuffer(queryData)
</h4>

<br />CheckBuffer:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Checks given Buffer and if there processes one request<br />
Params:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queryData : true if data is in nbNameQueryReq else data is in buffer<br />
Returns:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;see CheckSocket Enum values in CON section<br />
                    buffer contains last received request/response
                    _lastsendptr contains 0 or address response if any
<br />
<br /><a onclick ="javascript:ShowHide('lbl14')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl14><var>PUB</var> CheckBuffer(queryData) | buffptr, ptr, name, flag_s, protect, register 'checks given Buffer and if there processes one request      
  _lastsendptr := 0
  <var>if</var> queryData == <var>true</var>
    buffptr := @nbNameQueryReq - 8
  <var>else</var>
    buffptr := _buffPtr
    
  <var>RESULT</var> := CHECKSOCKET_OTHER                     'return typ 3 other as default
  flag_s := <var>byte</var>[buffPtr+constant(FLAGS+8)]
  <var>ifnot</var> ((flag_s &amp; $80) == $80)                   'just requests no responses            
    ptr := 0                                      'nothing
    protect := <var>false</var>                              'no
    register := <var>false</var>
    <var>if</var> ((flag_s&gt;&gt;3) == 5)                         'what op? is it register? 
       register := <var>true</var>                           'yes
    name := buffPtr+constant(QUERY+1+8)           'adress of query name
    <var>byte</var>[@ipResp-2] := 0                          'no group
    <var>if</var> <var>strcomp</var>(name,@encName)                     'query for host workstation?
      ptr := @encName
      protect := register
    <var>elseif</var> <var>strcomp</var>(name,@encServer)               'query for host server?
      ptr := @encServer
      protect := register
    <var>elseif</var> <var>strcomp</var>(name,@wildcard)                'query for wildcard?
      ptr := @wildcard
    <var>elseif</var> <var>strcomp</var>(name,@encGroup)                'query for group?
      <var>byte</var>[@ipResp-2] := $80                      'group
      ptr := @encGroup
             
    <var>if</var> ptr                                        'query for me?  
      <var>case</var> wiz.DeserializeWord(buffPtr + constant(NB_1+8)) 'what typ?
        NB:  
          <var>if</var> protect
              nbPosQueryResp[3] := RCODE_ACT_ERR  ' RCODE  ACT_ERR     0x6   Active error.  Name is owned by another node.  
              sendResponse(queryData, ptr, @nbPosQueryResp, constant(@enbPosQueryResp - @nbPosQueryResp))            
              <var>RESULT</var> := CHECKSOCKET_NEG_NB_SEND   'return typ 4 response (nbneg host)
          <var>else</var>
            <var>ifnot</var> register
              nbPosQueryResp[3] := 0              ' no RCODE
                sendResponse(queryData, ptr, @nbPosQueryResp, constant(@enbPosQueryResp - @nbPosQueryResp))            
              <var>RESULT</var> := CHECKSOCKET_NB_SEND       'return typ 1 response (nbpos host/group)
        NB_STAT:
          <var>ifnot</var>  ((queryData == <var>true</var>) <var>and</var> (_ownip &lt;&gt; _lastnbtstatip))
              sendResponse(queryData,ptr, @nbStatQueryResp, constant(@enbStatQueryResp - @nbStatQueryResp))            
            <var>RESULT</var> := CHECKSOCKET_NBSTAT_SEND     'return typ 2 response (nbstat host/group)

</pre>
<hr /><h4 id = "lbl15">GetLastSendPtr
</h4>
<br /><a onclick ="javascript:ShowHide('lbl16')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl16><var>PUB</var> GetLastSendPtr
  <var>return</var> _lastsendptr

</pre>
<hr /><h4 id = "lbl17">DisconnectSocket
</h4>

<br />DisconnectSocket: Processes all outstanding requests and disconnect Multi-Socket<br />

<br /><a onclick ="javascript:ShowHide('lbl18')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl18><var>PUB</var> DisconnectSocket | tmp                              'processes all outstanding requests and disconnect Multi-Socket
  <var>repeat</var>
    CheckSocket
  <var>until</var> (_lastReadSize == 0)
  sock.Disconnect

</pre>
<hr /><h4 id = "lbl19">ReInitSocket
</h4>

<br />ReInitSocket:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ReInit Mult-Socket for NetBios<br />

<br /><a onclick ="javascript:ShowHide('lbl20')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl20><var>PUB</var> ReInitSocket | tmp                                  'ReInit Mult-Socket for NetBios
  sock.Init(_sockId, UDP, 137) 
  sock.RemoteIp($FF, $FF, $FF, $FF)
  sock.RemotePort(137)
  sock.Open

</pre>
<hr /><h4 id = "lbl21">SendQuery(queryname, pad, suffix, nbstatIPaddress)
</h4>

<br />SendQuery:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Still Debug - send Query<br />

<br /><a onclick ="javascript:ShowHide('lbl22')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl22><var>PUB</var> SendQuery(queryname, pad, suffix, nbstatIPaddress)           'Still Debug - send Query
  <var>RESULT</var> := <var>word</var>[@nbNameQueryReq] := CreateTransactionId($FFFF) 
  FirstLevelEncode(@nbNameQueryReq+13, queryname, pad, suffix, <var>true</var>)
  <var>if</var> nbstatIPaddress
    _lastnbtstatip := <var>long</var>[nbstatIPaddress]
    <var>byte</var>[@nbNameQueryReq+3]  := $00                     'no Broadcast
    <var>byte</var>[@enbNameQueryReq-3] := NB_STAT                 'nb status query
    <var>ifnot</var> (_ownip == _lastnbtstatip)  
      sock.RemoteIp(<var>byte</var>[nbstatIPaddress][0], <var>byte</var>[nbstatIPaddress][1], <var>byte</var>[nbstatIPaddress][2], <var>byte</var>[nbstatIPaddress][3])
      sock.Send(@nbNameQueryReq, constant(@enbNameQueryReq - @nbNameQueryReq))
      sock.RemoteIp($FF, $FF, $FF, $FF) '?  
  <var>else</var>
    <var>byte</var>[@nbNameQueryReq+3]  := $10                     'Broadcast
    <var>byte</var>[@enbNameQueryReq-3] := NB                      'nb name query 
    sock.RemoteIp($FF, $FF, $FF, $FF)  
    sock.Send(@nbNameQueryReq, constant(@enbNameQueryReq - @nbNameQueryReq))
  
  sock.Available  '?

</pre>
<hr /><h4 id = "lbl23">GetLastReadSize
</h4>

<br />GetLastReadSize:&nbsp;&nbsp;Get lastReadSize .. size last recived frame<br />

<br /><a onclick ="javascript:ShowHide('lbl24')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl24><var>PUB</var> GetLastReadSize | tmp                               'get lastReadSize .. size last recived frame
  <var>RESULT</var> :=  _lastReadSize 

</pre>
<hr /><h4 id = "lbl25">GetLastIP
</h4>

<br />GetLastIP:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Still Debug - Get Ip ?not needed?<br />

<br /><a onclick ="javascript:ShowHide('lbl26')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl26><var>PUB</var> GetLastIP | tmp                                     'Still Debug - Get Ip ?not needed?
  <var>RESULT</var> :=  _buffPtr + constant(@ipResp - @nbPosQueryResp+8) 'adr ip

</pre>
<hr /><h4 id = "lbl27">DecodeLastNameInplace
</h4>

<br />DecodeLastNameInplace: Still Debug - decode Name in buffer for readability<br />

<br /><a onclick ="javascript:ShowHide('lbl28')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl28><var>PUB</var> DecodeLastNameInplace | tmp                         'Still Debug - decode Name in buffer for readability
  FirstLevelDecode(_buffPtr+21, _buffPtr+21)

</pre>
<hr /><h4 id = "lbl29">GetLastName
</h4>

<br />GetLastName:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Still Debug - give address of (decoded?) Name<br />

<br /><a onclick ="javascript:ShowHide('lbl30')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl30><var>PUB</var> GetLastName | tmp                                   'Still Debug - give address of (decoded?) Name
  <var>RESULT</var> := _buffPtr+21

</pre>
<hr /><br />
<h2 id = "lbl31">PRIvate Spin Methods </h2>
<hr /><h4 id = "lbl32">SendRegister(trn, encn, grp)
</h4>

<br />SendRegister:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Send register request<br />

<br /><a onclick ="javascript:ShowHide('lbl33')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl33><var>PRI</var> SendRegister(trn, encn, grp)                        'send register request
  <var>byte</var>[@ipReg-2] := grp                           
  <var>word</var>[@nbNameReg] := trn  
  <var>bytemove</var>(@nbNameReg+13, encn, 32)
  sock.Send(@nbNameReg, constant(@enbNameReg - @nbNameReg))

</pre>
<hr /><h4 id = "lbl34">SendResponse(queryData, name, response, size)
</h4>

<br />SendResponse:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Answer query<br />

<br /><a onclick ="javascript:ShowHide('lbl35')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl35><var>PRI</var> SendResponse(queryData, name, response, size)       'answer query
  _lastsendptr := response
  <var>bytemove</var>(response+13, name, 32)                       'set name
  <var>ifnot</var> queryData
    sock.RemoteIp(<var>byte</var>[_buffPtr], <var>byte</var>[_buffPtr+1], <var>byte</var>[_buffPtr+2], <var>byte</var>[_buffPtr+3])
    <var>bytemove</var>(response, _buffPtr+8, 2)                   'set trn
    sock.Send(response, size)
  sock.RemoteIp($FF, $FF, $FF, $FF)  

</pre>
<hr /><h4 id = "lbl36">WaitForCountBytes(count)
</h4>

<br />WaitForCountBytes: Wait for count bytes on socket<br />

<br /><a onclick ="javascript:ShowHide('lbl37')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl37><var>PRI</var> WaitForCountBytes(count)                            'wait for count bytes on socket
  <var>RESULT</var> := sock.DataReady
  <var>if</var> <var>RESULT</var> &lt; count                                     'If to less data
    <var>RESULT</var> := sock.Available                            'wait for more
    <var>if</var> <var>RESULT</var> &lt; count                                   'still to less data ... 
        sock.Disconnect                                 'error - reinit
        ReInitSocket                                    
        <var>RESULT</var> := 0

</pre>
<hr /><h4 id = "lbl38">FirstLevelEncode(dest, source, pad, suffix, touppercase)
</h4>

<br />FirstLevelEncode: Encode Name<br />

<br /><a onclick ="javascript:ShowHide('lbl39')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl39><var>PRI</var> FirstLevelEncode(dest, source, pad, suffix, touppercase) | char, size 'Encode the name
  size := <var>strsize</var>(source) &lt;# 15  
  <var>repeat</var> size                                           'Encode the name
    char := <var>byte</var>[source++] &amp; $FF
    <var>if</var> touppercase
      <var>if</var> char =&gt; "a"
        char := char &amp; (!$20)
    <var>byte</var>[dest++] := (char &gt;&gt; 4) + $41
    <var>byte</var>[dest++] := (char &amp; $0F) + $41    
  <var>repeat</var> 15 - size                                      'Pad spaces/zeros
    <var>byte</var>[dest++] := (pad &gt;&gt; 4) + $41
    <var>byte</var>[dest++] := (pad &amp; $0F) + $41  
  <var>byte</var>[dest++] := (suffix &gt;&gt; 4) + $41                   'Add the suffix
  <var>byte</var>[dest++] := (suffix &amp; $0F) + $41

</pre>
<hr /><h4 id = "lbl40">FirstLevelDecode(dest, source)
</h4>

<br />FirstLevelDecode: Decode Name<br />

<br /><a onclick ="javascript:ShowHide('lbl41')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl41><var>PRI</var> FirstLevelDecode(dest, source)                      'Decode Name
  <var>repeat</var> 15
    <var>byte</var>[dest++] := ((<var>byte</var>[source++] - $41) &lt;&lt; 4) + (<var>byte</var>[source++] - $41)
  <var>byte</var>[dest++] := "#"  
  <var>if</var> (<var>RESULT</var> := <var>byte</var>[source++] - $11) &gt; $39
    <var>RESULT</var> += 7     
  <var>byte</var>[dest++] := <var>RESULT</var> 
  <var>if</var> (<var>RESULT</var> := <var>byte</var>[source++] - $11) &gt; $39
    <var>RESULT</var> += 7     
  <var>byte</var>[dest++] := <var>RESULT</var> 
  <var>byte</var>[dest++] := 0 'terminate string

</pre>
<hr /><h4 id = "lbl42">CreateTransactionId(mask)
</h4>

<br />CreateTransactionId: Create Random TransactionId<br />

<br /><a onclick ="javascript:ShowHide('lbl43')" href="javascript:;">SOURCE CODE...</a>
<pre class=source id=lbl43><var>PRI</var> CreateTransactionId(mask)                           'Create Random TransactionId
  <var>RESULT</var> := <var>CNT</var>
  ?<var>RESULT</var>
  <var>RESULT</var> &amp;= mask

</pre>
<hr /><br />
<h2 id = "lbl44">Documentation </h2>
<pre>
This .spin file supports PhiPi's great Spin Code Documenter found at
http://www.phipi.com/spin2html/

You can at any time create a .htm Documentation out of the .spin source.

If you change the .spin file you can (re)create the .htm file by uploading your .spin file
to http://www.phipi.com/spin2html/ and then saving the the created .htm page. 
</pre>
<br />
<h2 id = "lbl45">MIT License </h2>
<pre>
 ______________________________________________________________________________________
|                            TERMS OF USE: MIT License                                 |                                                            
|______________________________________________________________________________________|
|Permission is hereby granted, free of charge, to any person obtaining a copy of this  |
|software and associated documentation files (the "Software"), to deal in the Software |
|without restriction, including without limitation the rights to use, copy, modify,    |
|merge, publish, distribute, sublicense, and/or sell copies of the Software, and to    |
|permit persons to whom the Software is furnished to do so, subject to the following   |
|conditions:                                                                           |
|                                                                                      |
|The above copyright notice and this permission notice shall be included in all copies |
|or substantial portions of the Software.                                              |
|                                                                                      |
|THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,   |
|INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A         |
|PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT    |
|HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF  |
|CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE  |
|OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                                         |
|______________________________________________________________________________________|
</pre>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
		</div>
	</td></tr>
</table>
</div>
</body>
</html>	
